
//
//  ShareUserVIew.m
//  SenMo
//
//  Created by ZengYuan on 15/12/23.
//  Copyright © 2015年 ZengYuan. All rights reserved.
//

#import "ShareUserVIew.h"
#import "Config.h"

@implementation ShareUserVIew

-(id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    
    self.backgroundColor = [UIColor clearColor];
    
    iconView = [[UIImageView alloc]init];
    [self addSubview:iconView];
    iconView.contentMode = UIViewContentModeScaleAspectFit;
    iconView.image = [UIImage imageNamed:@"head"];
    iconView.clipsToBounds = YES;
    iconView.layer.masksToBounds=YES;
    iconView.layer.cornerRadius = 3;
    iconView.backgroundColor = [UIColor clearColor];
    
    nameLabel  = [[UILabel alloc]init];
    [self addSubview:nameLabel];
    nameLabel.font = [UIFont systemFontOfSize:12];
    nameLabel.numberOfLines=2;
    nameLabel.textAlignment = NSTextAlignmentCenter;
    
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    UIView *superview = self;
    
    [iconView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.centerX.equalTo(self);
         make.centerY.equalTo(self).offset(-10);
         make.width.equalTo(@(50));
         make.height.equalTo(@(50));
    }];
    
    
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.bottom.equalTo(self.mas_bottom);
        make.left.equalTo(superview.mas_left);
        make.width.equalTo(superview);
        make.height.equalTo(@(30));
    }];
}

-(void)setUser:(UserUnit *)auser{
    
    _user = auser;
    
    nameLabel.text = auser.useruuid;

    if(auser.headImgUrl.length){
        iconView.image = [UIImage imageNamed:auser.headImgUrl];
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
